﻿using System;
using System.Collections.Generic;
using System.Text;
using NetworkLib.Utilities;

namespace PokemonBattle.BattleNetwork
{
    public class ByteSequence : DataByteArray
    {
        private List<byte> _elements = new List<byte>();

        public List<byte> Elements
        {
            get { return _elements; }
        }

        #region abstract

        public override void Read(ByteArray byteArray)
        {
            int count = byteArray.ReadInt();
            for (int i = 0; i < count; i++)
            {
                byte elem = byteArray.ReadByte();
                _elements.Add(elem);
            }
        }

        public override void Write(ByteArray byteArray)
        {
            byteArray.WriteInt(this.Elements.Count);
            foreach (byte elem in this.Elements)
            {
                byteArray.WriteByte(elem);
            }
        }

        #endregion
    }
}